load("C:/Users/wyatt/OneDrive - Colostate/MS Research/R_Git/CameronPeakFire/all_hr_AWS")
#import 15-minute data
fifteen_minute_uf_0804 <- read.table('C:/Users/wyatt/OneDrive - Colostate/MS Research/R_Git/CameronPeakFire/AWS/data/CR1000_7_Fifteen_Minute_0804.dat',
sep = ",", header = TRUE, skip = "1") %>%
slice(., -(1:2)) %>%
mutate(TIMESTAMP = ymd_hms(TIMESTAMP), TIMESTAMP = TIMESTAMP - hours(7)) %>%
mutate_if(is.character,as.numeric) %>%
mutate(site = 'uf')
fifteen_minute_bf_0804 <- read.table('AWS/data/CR1000XSeries - new_Fifteen_Minute_0804.dat',
sep = ",", header = TRUE, skip = "1") %>%
slice(., -(1:2)) %>%
mutate(TIMESTAMP = as.POSIXct(TIMESTAMP, tz = "UTC"))# %>% #, TIMESTAMP = TIMESTAMP - hours(7)) %>%
mutate_if(is.character,as.numeric) %>%
mutate(site = 'bf')
# create soilVUE DF
bf_0804_soil <- fifteen_minute_bf_0804 %>%
mutate(TIMESTAMP_LOCAL = as.POSIXct(format(TIMESTAMP, tz = "us/mountain", orgin = 'GMT', usetz = TRUE)),
.after = "TIMESTAMP")%>%
filter(TIMESTAMP_LOCAL >= "2022-08-04 00:00:00") %>%
select(-c(3:30))
write.csv(bf_0804_soil, file = "C:/Users/wreis/OneDrive - Colostate/MS Research/Meetings/08092022/BF soilVUE/bf_0804_soil.csv")
bf_0804_soil_VWC <- bf_0804_soil %>%
select(c(1,2, starts_with("VWC"))) %>%
pivot_longer(., cols = c(starts_with("VWC")), names_to = "depth", names_prefix = "VWC_",
values_to = "VWC", values_transform = as.numeric) %>%
mutate(depth = str_remove(depth, "cm_Avg"))
bf_0804_soil_Ka <- bf_0804_soil %>%
select(c(1,2, starts_with("Ka"))) %>%
pivot_longer(., cols = c(starts_with("Ka")), names_to = "depth", names_prefix = "Ka_",
values_to = "Ka", values_transform = as.numeric) %>%
mutate(depth = str_remove(depth, "cm_Avg"))
bf_0804_soil_T <- bf_0804_soil %>%
select(c(1,2, starts_with("T_"))) %>%
pivot_longer(., cols = starts_with("T_"), names_to = "depth", names_prefix = "T_",
values_to = "T", values_transform = as.numeric) %>%
mutate(depth = str_remove(depth, "cm_Avg"))
bf_0804_soil_BulkEC <- bf_0804_soil %>%
select(c(1,2, starts_with("BulkEC"))) %>%
pivot_longer(., cols = starts_with("BulkEC"), names_to = "depth", names_prefix = "BulkEC_",
values_to = "BulkEC", values_transform = as.numeric) %>%
mutate(depth = str_remove(depth, "cm_Avg"))
soil_data <- bf_0804_soil_VWC %>%
full_join(bf_0804_soil_Ka)%>%
full_join(bf_0804_soil_T)%>%
full_join(bf_0804_soil_BulkEC)
start_times <- which(soil_data$TIMESTAMP_LOCAL %in% as.POSIXct(c("2022-08-04 10:30:00",
"2022-08-04 12:15:00",
"2022-08-04 13:30:00")))
lims <- as.POSIXct(strptime(c("2022-08-04 09:00:00", "2022-08-04 15:00:00"), format = "%Y-%m-%d %H:%M:%S"))
# plot data
Ka_plot <- ggplot(soil_data, aes(x = TIMESTAMP_LOCAL, y = Ka, color = depth)) +
geom_line() +
geom_vline(xintercept = as.numeric(soil_data$TIMESTAMP_LOCAL[start_times]), size = 1,linetype="dotdash", color = "red") +
labs(title = "Ka Timeseries", x = "Date") +
scale_color_discrete(limits = c("5", "10", "20", "30", "40", "50")) +
scale_x_datetime(limits = lims, date_labels = "%H:%M", date_breaks = "1 hour")
Ka_plot
BulkEC_plot <- ggplot(soil_data, aes(x = TIMESTAMP_LOCAL, y = BulkEC, color = depth)) +
geom_line() +
geom_vline(xintercept = as.numeric(soil_data$TIMESTAMP_LOCAL[start_times]), size = 1,linetype="dotdash", color = "red") +
labs(title = "BulkEC Timeseries", x = "Date") +
scale_color_discrete(limits = c("5", "10", "20", "30", "40", "50")) +
scale_x_datetime(limits = lims, date_labels = "%H:%M", date_breaks = "1 hour")
BulkEC_plot
VWC_plot <- ggplot(soil_data, aes(x = TIMESTAMP_LOCAL, y = VWC, color = depth)) +
geom_line() +
geom_vline(xintercept = as.numeric(soil_data$TIMESTAMP_LOCAL[start_times]), size = 1,linetype="dotdash", color = "red") +
labs(title = "VWC Timeseries", x = "Date") +
scale_color_discrete(limits = c("5", "10", "20", "30", "40", "50")) +
scale_x_datetime(limits = lims, date_labels = "%H:%M", date_breaks = "1 hour")
VWC_plot
T_plot <- ggplot(soil_data, aes(x = TIMESTAMP_LOCAL, y = T, color = depth)) +
geom_line() +
geom_vline(xintercept = as.numeric(soil_data$TIMESTAMP_LOCAL[start_times]), size = 1,linetype="dotdash", color = "red") +
labs(title = "T Timeseries", x = "Date") +
scale_color_discrete(limits = c("5", "10", "20", "30", "40", "50")) +
scale_x_datetime(limits = lims, date_labels = "%H:%M", date_breaks = "1 hour")
T_plot
#BF 20 and 30 cm
#UF 50 and 60 cm
#SoilVUE Ka Data
all_soil_Ka <- all_hr %>%
subset(site != "jw") %>%
select(c(TIMESTAMP, site,
Ka_20cm_Avg, Ka_30cm_Avg, Ka_50cm_Avg, Ka_60cm_Avg)) %>%
filter(TIMESTAMP > ymd_hms("2021-11-01 00:00:00")) %>%
mutate(date = as_date(TIMESTAMP))
#Daily data
all_soil_Ka_daily <- all_soil_Ka %>%
select(-TIMESTAMP) %>%
group_by(date, site) %>%
summarise(across(everything(), mean, na.rm = TRUE))
## `summarise()` has grouped output by 'date'. You can override using the
## `.groups` argument.
all_soil_Ka_daily_long <- all_soil_Ka_daily %>%
pivot_longer(., cols = c(starts_with("Ka")), names_to = "depth", names_prefix = "Ka_",
values_to = "Ka", values_transform = as.numeric) %>%
mutate(depth = str_remove(depth, "cm_Avg"))%>%
na.omit() %>%
filter((site == "bf" & (depth == "20" | depth == "30")) |
(site == "uf" & (depth == "50" | depth == "60")))
Ka_plot <- ggplot(all_soil_Ka_daily_long, aes(x = date, y = Ka, color = site, linetype= depth)) +
geom_line() +
labs(title = "Ka Timeseries", x = "Date", color = "(Site,", linetype = "Depth)")
Ka_plot

ggplotly(Ka_plot)
#SoilVUE T Data
all_soil_T <- all_hr %>%
subset(site != "jw") %>%
select(c(TIMESTAMP, site,
T_5cm_Avg, T_10cm_Avg, T_20cm_Avg, T_30cm_Avg, T_40cm_Avg, T_50cm_Avg, T_60cm_Avg,
T_75cm_Avg, T_100cm_Avg)) %>%
filter(TIMESTAMP > ymd_hms("2021-11-01 00:00:00")) %>%
mutate(date = as_date(TIMESTAMP))
all_soil_T_hr_long <- all_soil_T %>%
select(-date) %>%
pivot_longer(., cols = c(starts_with("T_")), names_to = "depth", names_prefix = "T_",
values_to = "T", values_transform = as.numeric) %>%
mutate(depth = str_remove(depth, "cm_Avg")) %>%
na.omit()
#Daily data
all_soil_T_daily <- all_soil_T %>%
select(-TIMESTAMP) %>%
group_by(date, site) %>%
summarise(across(everything(), list(mean = mean), na.rm = TRUE))
## `summarise()` has grouped output by 'date'. You can override using the
## `.groups` argument.
all_soil_T_daily_long <- all_soil_T_daily %>%
pivot_longer(., cols = c(starts_with("T")), names_to = "depth", names_prefix = "T_",
values_to = "T", values_transform = as.numeric) %>%
mutate(depth = str_remove(depth, "cm_Avg"))
T_plot <- ggplot(all_soil_T_hr_long, aes(x = TIMESTAMP, y = T, color = site, linetype= depth)) +
geom_line() +
labs(title = "T Timeseries", x = "Date")
T_plot

ggplotly(T_plot) %>% layout(hovermode = "x unified")